<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2020-2030 衡水山木枝技术服务有限公司
 * @Date: 2021-10-19 10:40:48
 * @Description: 用户领到的优惠券
 * @LastEditors: 李志刚
 * @LastEditTime: 2021-10-21 15:06:20
 * @FilePath: /team_commission/database/migrations/shop/expand/2021_10_19_104048_create_user_coupon.php
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserCoupon extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_coupons', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->id();
            $table->foreignId('user_id')->default(0)->comment('用户ID');
            $table->foreignId('coupon_id')->default(0)->comment('优惠券ID');
            $table->tinyInteger('type')->default(0)->comment('类型 1满减 2金额优惠券 3折扣优惠券');
            $table->tinyInteger('source')->default(0)->comment('来源 1直接领取 2生日券 3节日 4充值卡');
            $table->date('due_time')->nullable()->comment('到期时间');
            $table->unsignedDecimal('price')->default(0)->comment('减免金额');
            $table->unsignedDecimal('base_price')->default(0)->comment('需满足金额');
            $table->unsignedInteger('discount')->default(0)->comment('折扣');
            $table->boolean('status')->default(1)->comment('状态 1正常 0禁用');
            $table->tinyInteger('del_flag')->default(0)->comment('删除状态（1删除 0正常）');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_coupons');
    }
}
